package com.snowflake.ecatalog.entity;

import java.util.Map;

import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.collect.Maps;

/**
 * 资源路径
 */
// JPA标识
@Entity
@Table(name = "t_ec_resourceinfo")
public class ResourceInfo extends IdEntity {
	private Long ownerId;
	private int ownerType;
	private String physicalPath;
	private String webPath;
	private String fileName;
	private int sequence;

	public ResourceInfo() {
		super();
	}

	public ResourceInfo(Long id) {
		super();
		this.id = id;
	}

	public Long getOwnerId() {
		return ownerId;
	}

	public void setOwnerId(Long ownerId) {
		this.ownerId = ownerId;
	}

	public int getOwnerType() {
		return ownerType;
	}

	public void setOwnerType(int ownerType) {
		this.ownerType = ownerType;
	}

	@JsonIgnore
	public String getPhysicalPath() {
		return physicalPath;
	}

	public void setPhysicalPath(String physicalPath) {
		this.physicalPath = physicalPath;
	}

	@JsonIgnore
	public String getWebPath() {
		return webPath;
	}

	public void setWebPath(String webPath) {
		this.webPath = webPath;
	}

	@JsonIgnore
	public String getFileName() {
		return fileName;
	}

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	public int getSequence() {
		return sequence;
	}

	public void setSequence(int sequence) {
		this.sequence = sequence;
	}

	@Transient
	public String getImgSrcPath() {
		return getWebPath() + getFileName();
	}

	@Transient
	public Map<String, String> getImgSrcMap() {
		Map<String, String> map = Maps.newHashMap();
		map.put("path", getWebPath());
		map.put("filename", getFileName());
		return map;
	}
}
